home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
'92_HACK
/
IR_MAN_
/
KILLAPP.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-06-07
|
1KB
|
47 lines
#include "KillApp.h"
/**********************************
QuitApps
DTS Code Snippet to quit all running applications (except yourself)
note: to work properly, the calling application must have a standard
event loop with menus (to support puppet string quits for apps that
don't support core appleevents.
note#2: remember to set the applevent aware flag in your app if you use
this code
written by Steven Falkenburg 9/4/91
**********************************/
/* quits an app of the given process id */
OSErr QuitAnApp(ProcessSerialNumber *proc)
{
OSErr err;
AEAddressDesc target;
AppleEvent theAE,aeReply;
theAE.dataHandle = aeReply.dataHandle = target.dataHandle = nil;
err = AECreateDesc(typeProcessSerialNumber,(Ptr)proc,sizeof(ProcessSerialNumber),&target);
if (err!=noErr)
return err;
err = AECreateAppleEvent(kCoreEventClass,kAEQuitApplication,&target,
kAutoGenerateReturnID,kAnyTransactionID,&theAE);
if (err!=noErr) {
AEDisposeDesc(&target);
return err;
}
err = AESend(&theAE,&aeReply,kAENoReply,kAENormalPriority,kNoTimeOut,nil,nil);
AEDisposeDesc(&target);
AEDisposeDesc(&theAE);
return err;
}